package main

import (
	"fmt"
	"regexp"
)

func main(){
	ok, _ := regexp.MatchString("^(a|b)", "ca1")
	fmt.Println(ok)

	text := `Hello 世界！123 "$Go".`
	reg := regexp.MustCompile(`[a-z]+`)
	fmt.Printf("%q\n", reg.FindAllString(text, -1))

    text = `disk_free{job="$job",instance="$instance"}`
	reg = regexp.MustCompile(`(?U)"\$.*"`)
	fmt.Printf("%q\n", reg.FindAllString(text, -1))

    text = `label_values(disk_free{job=\"$job\",instance=\"$instance\"},mount)`
    reg = regexp.MustCompile(`label_values[(](.*?)[)]`)
    fmt.Printf("%q\n", reg.FindStringSubmatch(text))

    // 取出{}里的数据
    text = `df{a,b,c}`
    reg = regexp.MustCompile(`{(.*?)}`)
    fmt.Println(reg.FindStringSubmatch(text))
    fmt.Println(reg.FindStringIndex(text))

    text = `mount="$mount"`
    reg = regexp.MustCompile(`"\$(.*?)"`)
	fmt.Println(reg.FindStringSubmatch(text))

    text = "irate([1m]net_in_total[5m]"
    reg = regexp.MustCompile(`\[(.*?)\]`)
    fmt.Println(reg.FindAllStringSubmatch(text, -1))

    text = `disk_free{job="prometheus",instance1="$instance",mount1="$mount"}`
    reg = regexp.MustCompile(`"\$(.*?)"`)
    fmt.Println(reg.FindAllStringSubmatch(text, -1))

}

